package com.dobby.logger.system.thread;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.concurrent.Callable;

/**
 * Created by liguoqing on 2016/3/11.
 */
public class MyCallable implements Callable<Object> {

    private static final Logger logger = LoggerFactory.getLogger(MyCallable.class);

    private String taskNo;

    public MyCallable(String taskNo) {
        this.taskNo = taskNo;
    }

    @Override
    public Object call() throws Exception {
        logger.info("=====>任务"+ taskNo + "启动");
        Date date1 = new Date();
        Thread.sleep(2000);
        Date date2 = new Date();
        long time = date2.getTime() - date1.getTime();
        logger.info("======>" + taskNo + "任务终止");
        return "任务"+taskNo+"返回运行结果，当前任务时间【"+time+"毫秒】";
    }

}
